package com.youlai.boot.modules.exhibition.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youlai.boot.modules.exhibition.converter.ExhibitionShopConverter;
import com.youlai.boot.modules.exhibition.mapper.ExhibitionShopMapper;
import com.youlai.boot.modules.exhibition.model.ExhibitionShop;
import com.youlai.boot.modules.exhibition.model.ExhibitionShopForm;
import com.youlai.boot.modules.exhibition.model.ExhibitionShopVO;
import com.youlai.boot.modules.exhibition.service.ExhibitionShopService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class ExhibitionShopServiceImpl extends ServiceImpl<ExhibitionShopMapper, ExhibitionShop>
        implements ExhibitionShopService {

    private final ExhibitionShopConverter exhibitionShopConverter;

    @Override
    public Page<ExhibitionShopVO> getExhibitionShopPage(Long exhibitionId, Long shopId, Integer boothType,
            Integer status,
            int pageNum, int pageSize) {
        Page<ExhibitionShopVO> page = new Page<>(pageNum, pageSize);
        return baseMapper.getExhibitionShopPage(page, exhibitionId, shopId, boothType, status);
    }

    @Override
    public ExhibitionShopVO getExhibitionShopById(Long id) {
        ExhibitionShop exhibitionShop = this.getById(id);
        return exhibitionShopConverter.toVO(exhibitionShop);
    }

    @Override
    public Long saveExhibitionShop(ExhibitionShopForm form) {
        ExhibitionShop exhibitionShop = exhibitionShopConverter.toEntity(form);
        this.save(exhibitionShop);
        return exhibitionShop.getId();
    }

    @Override
    public void updateExhibitionShop(ExhibitionShopForm form) {
        ExhibitionShop exhibitionShop = exhibitionShopConverter.toEntity(form);
        this.updateById(exhibitionShop);
    }

    @Override
    public boolean deleteExhibitionShop(Long id) {
        return this.removeById(id);
    }
}